﻿<script type="text/javascript">
 $(document).ready(function(){
   $("#btn_login").click(function(event){	   
		$.ajax({
		   contentType: 'application/json',
		   type: "POST",
		   url: "/aib_login/",
		   dataType: 'html',
		   data: (function() {
						var parametros = {};
						var theForm = window.document.LoginForm;
						var num_of_elements = theForm.length;
						//alert(num_of_elements);
						for (var i=0; i<num_of_elements; i++){
							var theElement = theForm.elements[i];
							var element_type = theElement.type;
							var element_name = theElement.name;
							var element_value = theElement.value;
							if(element_type=="radio"){
								if (theElement.checked==true){
									parametros[element_name]=element_value;
								}
							}else{
								parametros[element_name]=element_value;
								//alert(parametros[element_name]);
							}
						}
						
						return parametros;
					})(),
		   success: function(resp) {
						var key = resp;						
						var i = 0;
						//alert(key);
						if (key.indexOf("success")>-1){
							$("#sucesso_dialog").dialog({
															modal: true,
															resizable: false,
															height: 170,
															buttons: {
																Ok: function() {
																	$(this).dialog('close');
																}
															}
														});
														
							content_manager_ajax('middle_content','middle_content_info.html');
							content_manager_ajax('right_content_top','menu_dir_temp_login.html');
							content_manager_ajax('left_content_top','navigation_temp_menu_esq.html');
							//location.href = 'complete/' //redireciona pra pagina completa
						}else if (key.indexOf("fail")>-1){
							$("#fail_dialog").dialog({
															modal: true,
															resizable: false,
															height: 170,
															buttons: {
																Ok: function() {
																	$(this).dialog('close');
																}
															}
														});
														
						}else if (key.indexOf("disable")>-1){
							$("#disable_dialog").dialog({
															modal: true,
															resizable: false,
															height: 170,
															buttons: {
																Ok: function() {
																	$(this).dialog('close');
																}
															}
														});
														
						}
						return;	
						
					},
			error: function() {
				// Prompt for user data and process the result using a callback:
				//alert('Falha de conexao com o servidor.');
				$("#erro_dialog").dialog({ resizable: false });
			},
		 });
   });
 });
</script>

<div id="disable_dialog" title="Desabilitado" style="display: none; ">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span> 
<span style="padding-top:10px; font-size:16px;font:Verdana, Geneva, sans-serif;">Usuário não ativo.<br/>Por favor entre em contato com o suporte.
</span>
</p>
</div>

<div id="fail_dialog" title="Falha" style="display: none; ">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span> 
<span style="padding-top:10px; font-size:16px;font:Verdana, Geneva, sans-serif;">Usuário ou senha incorretos.<br/>Insira usuário e senha corretos e tente novamente.
</span>
</p>
</div>

<div id="sucesso_dialog" title="Sucesso" style="display: none; ">
<p>
<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span> 
<span style="padding-top:10px; font-size:16px;font:Verdana, Geneva, sans-serif;">Login feito com sucesso.<br/>Bem vindo!
</span>
</p>
</div>

<div id="erro_dialog" title="Erro" style="display: none; ">
	<p>Falha na conexao com o servidor.</p>
</div>

<!-- Pagetitle -->
<h1 class="pagetitle">Acessando Conta:</h1> 
 
    <div class="column1-unit"> 
<div class="contactform"> 
<form action="/admin/" method="post" id="LoginForm" name="LoginForm"> 
<fieldset><legend>&nbsp;*Dados Obrigatórios:&nbsp;</legend> 
       
        <div class="fieldWrapper"> 
            
            <div id="username_erro"></div> 
            <p>
              <label class="left" for="username"><span class="obrigatorio">*Usuário</span></label> 
            <input id="id_username" type="text" class="field" name="username" maxlength="30" />
			<input type="hidden" name="this_is_the_login_form" value="1" />
            </p> 
        </div> 
    
        <div class="fieldWrapper"> 
            
            <div id="password1_erro"></div> 
            <p>
              <label class="left" for="password1"><span class="obrigatorio">*Senha</span></label> 
            <input id="id_password" type="password" name="password" class="field"/> 
            </p> 
        </div>     
</fieldset>
<p><input class="button" id="btn_login" type="button" value="Entrar" /></p> 
</form> 
  </div>              
</div>
<script type="text/javascript"> 
document.getElementById('id_username').focus()
</script>